/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import model.entities.Report;


/**
 *
 * @author Hieu.Nguyen
 */
public class ReportDAO {
    private static ReportDAO reportDAO;

    public static ReportDAO getInstance() {
        if (reportDAO == null) {
            reportDAO = new ReportDAO();
        }
        return reportDAO;
    }
    
     public List<Report> getReport(boolean isActived) {
        List<Report> listReport = new ArrayList<Report>();
        try {
            Connection conn = ConnectionFactory.getConnection();
            String sql = "select * from tblReport";
            PreparedStatement pstmt = conn.prepareStatement(sql);
            
            ResultSet rs = pstmt.executeQuery();
            while (rs.next()) {
                Report r = new Report();
                r.setReportID(rs.getInt("ReportID"));
                r.setReportType(rs.getString("ReportType"));
                r.setReportName(rs.getString("ReportName"));
                r.setReportDesc(rs.getBoolean("ReportDesc")); 
                listReport.add(r);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return listReport;
    }
    
}
